<?php

namespace App\Http\Controllers\Api\V2;

use Illuminate\Http\Request;
use App\Http\Requests\ApiV2\PartsCategoryRequest;
use App\Services\Warehouse\Interfaces\PartsCategoryServiceInterface;
use Illuminate\Support\Facades\DB;
use App\Services\Warehouse\Services\PartsCategoryService;

class PartsCategoryController extends BaseController
{
    /**
     * @var PartsCategory
     */
    protected $partsCategoryService;

    public function __construct(PartsCategoryServiceInterface $partsCategoryService)
    {
        $this->partsCategoryService = $partsCategoryService;
    }


    public function index(Request $request)
    {
        $vendor = $this->partsCategoryService->index($request->all());
        return $this->data($vendor);
    }

    public function store(PartsCategoryRequest $request)
    {
        $this->partsCategoryService->set($request->filldata());
        return $this->success();
    }

    public function edit($id)
    {
        $vendor = $this->partsCategoryService->get($id);
        return $this->data($vendor);
    }

    public function update(PartsCategoryRequest $request, $id)
    {
        $this->partsCategoryService->set($request->filldata(), $id);
        return $this->success();
    }

    public function destroy($id)
    {
        $this->partsCategoryService->destroy($id);
        return $this->success();
    }
}
